package com.song.mall.product.web;

import com.song.mall.product.service.SkuInfoService;
import com.song.mall.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

/**
 * @author 宋超
 * HP - the login name of the current user.
 * 2021/10/2 - the current system date.
 * 11:39 - the current system time.
 */
@Controller
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;

    /**
     * 展示当前sku详情页
     * @param skuId
     * @return
     */

    @GetMapping("/{skuId}.html")
    public String SkuItem(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {
        System.out.println("--------------"+skuId+"--------------");
        SkuItemVo skuItemVo =  skuInfoService.item(skuId);
        //System.out.println(skuItemVo);

        model.addAttribute("item",skuItemVo);
        return "item";
    }
}
